//
//  MKTChatItem_3_TVCell.m
//  MKUITestApp
//
//  Created by 苏尚进 on 2021/7/13.
//  Copyright © 2021 moon. All rights reserved.
//

#import "MKTChatItem_3_TVCell.h"

@implementation MKTChatItem_3_TVCell
+ (void)load{
    [self registerTableViewCellFor:[MKTChatItem_3 class]];
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.leftView = [[MKTChatTextBlockUIView alloc] init];
        
        self.leftView.flowlayout.constraintParam = MKUIFlowLayoutConstraintParam_H_C_L;
        [self.contentView addSubview:self.leftView];
        //
        self.rightView = [[MKTChatTextBlockUIView alloc] init];
        
        self.rightView.flowlayout.constraintParam = MKUIFlowLayoutConstraintParam_H_C_R;
        [self.contentView addSubview:self.rightView];
        
        //
        UIFont *font = [UIFont systemFontOfSize:12];
        self.leftView.titleView.font = font;
        self.leftView.valueView.textFont = font;
        self.leftView.valueView.moneyUnitFont = font;
        self.leftView.valueView.hintFont = font;
        
        self.rightView.titleView.font = font;
        self.rightView.valueView.textFont = font;
        self.rightView.valueView.moneyUnitFont = font;
        self.rightView.valueView.hintFont = font;
        //
        self.flowlayout = [[MKUISegmentFlowLayoutConstraint alloc] initWithItems:@[self.leftView,self.rightView] constraintParam:(MKUISegmentFlowLayoutConstraint_H_T) contentInsets:UIEdgeInsetsMake(2, 10, 2, 10) interitemSpacing:5];
        self.flowlayout.layoutPriorityItemsMaxBoundsPercent = 0.5;
    }
    return self;
}
- (void)customLayoutSubviews{
    [super customLayoutSubviews];
    CGRect bounds = self.contentView.bounds;
    self.flowlayout.bounds = bounds;
    [self.flowlayout layoutItemsWithResizeItems:YES];
}
- (CGSize)customSizeThatFits:(CGSize)size{
    return [self.flowlayout sizeThatFits:size resizeItems:YES];
}
- (void)customReloadCellModel{
    [super customReloadCellModel];
    MKTChatItem_LeftRight *modelValue = self.cellModel.modelValue;
    self.leftView.textBlock = modelValue.left;
    [self.leftView reloadData];
    self.rightView.textBlock = modelValue.right;
    [self.rightView reloadData];
}
@end
